﻿Public Class TipoErrorRecetaDAO
    Public Shared Function obtenerTiposErroresReceta(ByVal TipoErrorRecetaId As Integer) As DataTable
        Dim cn As SqlClient.SqlConnection = Nothing
        Try
            cn = Conexion.Conectar
            Dim ds As New DataSet
            Dim da As New SqlClient.SqlDataAdapter("usp_tipoErrorReceta_obtener", cn)
            da.SelectCommand.CommandType = CommandType.StoredProcedure
            da.SelectCommand.Parameters.AddWithValue("@TipoErrorRecetaId", TipoErrorRecetaId).DbType = DbType.Int32
            da.Fill(ds, "TipoErrorReceta")

            Return ds.Tables("TipoErrorReceta")
        Catch ex As Exception
            'GUARDAMOS EL ERROR EN LA BD
            ErrorDAO.insertarError(ex)
            Return Nothing
        Finally
            Conexion.Desconectar(cn) 'PASAR POR PARAMETRO LA CONEXION
        End Try
    End Function

    Public Shared Function obtenerUbicacion(ByVal TipoErrorRecetaId As Integer) As String
        Dim cn As SqlClient.SqlConnection = Nothing
        Try
            cn = Conexion.Conectar
            Dim command As SqlClient.SqlCommand
            command = New SqlClient.SqlCommand("usp_tipoErrorReceta_ubicacion", cn)
            command.CommandType = CommandType.StoredProcedure
            command.Parameters.AddWithValue("@TipoErrorRecetaId", TipoErrorRecetaId).DbType = DbType.Int32
            Dim s As String = command.ExecuteScalar
            Return s

        Catch ex As Exception
            'GUARDAMOS EL ERROR EN LA BD
            ErrorDAO.insertarError(ex)
            Return ""
        Finally
            Conexion.Desconectar(cn) 'PASAR POR PARAMETRO LA CONEXION
        End Try
    End Function
End Class
